package com.quarters.config.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Zhang on 2018/8/26.
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    @Bean
    public Appinterceptor appinterceptor() {
        return new Appinterceptor();
    }
    @Bean
    public Admininterceptor admininterceptor() {
        return new Admininterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //配置 不需要拦截的包和请求
   String[] AppExcludePathPatterns=new String[]{
           "/css/**",
           "/fonts/**",
           "/frame/**",
           "/images/**",
           "/wangEdit/**",
           "/error/**",
           "/wx/user/login",
           "/wx/user/paySuccess",
           "/wx/noticeOrder/paySuccess",
           "/wx/user/success_pay.html",
           "/checkToken"

   };
        //配置 不需要拦截的包和请求
   String[] AdminExcludePathPatterns=new String[]{
           "/css/**",
           "/fonts/**",
           "/frame/**",
           "/images/**",
           "/wangEdit/**",
           "/error/**",
           "/admin/userInfo/login.html",
           "/admin/userInfo/pay.html",
           "/admin/userInfo/error.html",
           "/admin/userInfo/login"

   };
        registry.addInterceptor(  appinterceptor()).addPathPatterns("/wx/**").excludePathPatterns(AppExcludePathPatterns);
        registry.addInterceptor(  admininterceptor()).addPathPatterns("/admin/**").excludePathPatterns(AdminExcludePathPatterns);
    }


}
